#ifndef SERVICES_H
#define SERVICES_H

#include <QObject>
#include "../session/session.h"
#include "../connecttodatabase/connecttodatabase.h"
#include "../sqlmodel/lqsqlrelationaltablemodel.h"
#include "../sqlmodel/sqlquerymodel.h"
#include <QStringList>
#include <QQmlContext>
#include <QSqlRelationalTableModel>

class QString;
class Services : public QObject
{
    Q_OBJECT
public:
    Services(QQmlContext *ctxt, Session *sess);
    Q_INVOKABLE bool start();
    Q_INVOKABLE void stop();
    Q_INVOKABLE int isRunning(void)const;
    Q_INVOKABLE bool doLogin(QString username, QString password);
    Q_INVOKABLE QStringList getLibRoomNames();
    Q_INVOKABLE QStringList getBroadcastFileNames();
    Q_INVOKABLE QStringList getBroadcastTypes();
    Q_INVOKABLE LQSqlRelationalTableModel *getAuthlogModel(QString libname, QString authtime);
    Q_INVOKABLE LQSqlRelationalTableModel *getTalklogModel(QString libname, QString talktime);
    Q_INVOKABLE LQSqlRelationalTableModel *getWarnlogModel(QString libname, QString warntype, QString warntime);
    Q_INVOKABLE LQSqlRelationalTableModel *getBroadcastlogModel(QString bc_type,  QString bc_time);
    Q_INVOKABLE SqlQueryModel *getUserModel(void);
    Q_INVOKABLE bool delBroadCastFileName(QString fname);
    Q_INVOKABLE bool addBroadCastFileName(QString fname);

    Q_INVOKABLE bool update_warn_status(int id);
    Q_INVOKABLE QStringList getTeams();
public slots:
    void changeName(QString username);
private:
    ConnectToDatabase m_con;
    QQmlContext *m_ctxt;
    Session *m_ses;
    bool _isRunning;
    LQSqlRelationalTableModel *_auth_model;
    LQSqlRelationalTableModel *_talk_model;
    LQSqlRelationalTableModel *_warn_model;
    LQSqlRelationalTableModel *_bc_model;
    SqlQueryModel *_user_model;
    QSqlQuery *_query;
};



#endif // SERVICES_H
